import Vue from 'vue'
import App from './App.vue'

import VueRouter from 'vue-router'

Vue.use(VueRouter)

import VueResource from 'vue-resource'

Vue.use(VueResource)

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);


// 1.创建组件
import Home from "./components/home.vue";
import News from "./components/news.vue";


// 2.配置路由
const routers = [
  { path: '/home', component: Home },
  { path: '/news', component: News }
]

// 3.实例化VueRouter
const router = new VueRouter({
  //mode: "history",//默认的hash模式变成history模式，去掉url中乱七八糟的#等符号。
  // routes 
  //缩写，相当于routers: routers
  routes: routers
})

// 4. 挂载路由
new Vue({
  el: '#app',
  router,
  render: h => h(App)
})

// 5. <router-view></router-view> 放在App.vue里面（动态加载路由）
